package com.rppowell.pixie.models;

import java.util.ArrayList;

public class SpriteSet extends ArrayList<Sprite> {

    /**
     *
     */
    private static final long serialVersionUID = 1L;
    private SpriteSetProperties properties;
    private MapSet maps;

    public SpriteSet(int width, int height) {
        this(new SpriteSetProperties(width, height));
    }

    public SpriteSet(SpriteSetProperties p) {
        properties = p;
        maps = new MapSet(this);
    }

    public String getName() {
        return properties.getName();
    }

    public void setName(String name) {
        properties.setName(name);
    }

    public Sprite addSprite(Sprite s) throws Exception {
        if (this.properties.getSpriteWidth() != s.getWidth() || this.properties.getSpriteHeight() != s.getHeight()) {
            throw new Exception(this.getClass().getName() + "@" + this.hashCode() + ":\"sprite size mismatch\"");
        }
        this.add(s);
        return s;
    }

    public Map newMap(int w, int h, String name) {
        return maps.newMap(w, h, name);
    }

    public MapSet getMapSet() {
        return maps;
    }

    public SpriteSetProperties getSpriteSetProperties() {
        return properties;
    }
}
